package com.fico.blaze;

import com.blazesoft.repository.file.NdFileRepositoryConnection;
import com.blazesoft.template.repository.NdRomConnectionException;
import com.blazesoft.template.repository.NdRomConnectionManager;
import com.blazesoft.template.repository.NdRomException;
import com.blazesoft.template.repository.NdRomFactory;
import lombok.AllArgsConstructor;
import lombok.Data;


@Data
@AllArgsConstructor
public class BlazeConnectionManager {
    //库路径
    private String repositoryPath;

    //库用户名
    private String userName;

    //库密码
    private String password;

    public NdRomConnectionManager getConnectionManagerInstance(){
        NdFileRepositoryConnection connection = new NdFileRepositoryConnection();
        connection.setRepositoryFolder(repositoryPath);
        connection.setUser(userName);
        connection.setPassword(password);
        NdRomConnectionManager connectionManager = null;
        try {
            connectionManager = NdRomFactory.newRepositoryConnectionManager(connection);
            connectionManager.connect();
            return connectionManager;
        } catch (NdRomConnectionException e) {

            e.printStackTrace();
        } catch (NdRomException e) {

            e.printStackTrace();
        }
        return connectionManager;
    }

}
